﻿using Angle.Krill.Utils;
using AntdUI;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace Angle.Krill
{
    internal class FormHelper
    {
        private static string dllPath = Path.Combine(Application.StartupPath, "Angle.Krill.exe");
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="clsFullName"></param>
        public static void Show(string clsFullName)
        {
            InstanceForm(clsFullName).Show();
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="clsFullName"></param>
        public static void ShowDialog(string clsFullName)
        {
            InstanceForm(clsFullName).ShowDialog();
        }
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="clsFullName"></param>
        public static Form InstanceForm(string clsFullName)
        {
            Form form = ReflectionHelper.Instance(dllPath, clsFullName) as Form;

            return form;
        }
        public static void LoadFormIntoPanel(System.Windows.Forms.Panel panel, Form formToLoad)
        {
            panel.Controls.Clear();

            formToLoad.TopLevel = false;
            formToLoad.FormBorderStyle = FormBorderStyle.None;
            formToLoad.Dock = DockStyle.Fill;
            panel.Controls.Add(formToLoad);
            formToLoad.Show();
        }
    }
}
